﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMLSpreadGear.Core;

namespace XMLSpreadGear.Headers
{
    public class Worksheet:BaseElement
    {
        private string sName;

        public string Name
        {
            get { return sName; }
            set { sName = value; }
        }
        private bool? bProtected;

        public bool? Protected
        {
            get { return bProtected; }
            set { bProtected = value; }
        }
        private bool? bRightToLeft;

        public bool? RightToLeft
        {
            get { return bRightToLeft; }
            set { bRightToLeft = value; }
        }

        public Worksheet(string strlocalname,string name)
            : base(strlocalname)
        {
            this.sName = name;
        }

        public Worksheet(string strlocalname, string name, bool bprotected, bool righttoLeft)
            : this(strlocalname,name)
        {
            this.bProtected = bprotected;
            this.bRightToLeft = righttoLeft;
        }

        internal protected override IDictionary<string, string> RegisterElements()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            return dic;
        }

        internal protected override IDictionary<string, string> RegisterAttributes()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();

            dic.Add("Name", this.Name);

            if(this.Protected != null)
                dic.Add("Protected", this.Protected.ToByte().ToString());

            if(this.RightToLeft !=null)
                dic.Add("RightToLeft", this.RightToLeft.ToByte().ToString());

            return dic;
        }

        protected override void SetDefaults()
        {
            return;
        }

        internal override string GetAttributeNamespace()
        {
            return Contstants.SpredsheetAttributePrefix;
        }

        internal override string GetAttributeNamespaceURI()
        {
            return Contstants.SpredsheetAttributeNamespace;
        }
    }
}
